{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "f8e69328-6649-48e1-bfca-06d38afd415b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.66666667 1.         0.66666667]\n",
      "0.8000000000000002\n",
      "0.7777777777777777\n",
      "0.8\n",
      "0.5\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.8/site-packages/sklearn/metrics/_classification.py:1570: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in samples with no true nor predicted labels. Use `zero_division` parameter to control this behavior.\n",
      "  _warn_prf(average, \"true nor predicted\", \"F-score is\", len(true_sum))\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import f1_score\n",
    "y_true = [[0, 0, 0], [1, 1, 1], [0, 1, 1]]\n",
    "y_pred = [[0, 0, 0], [1, 1, 1], [1, 1, 0]]\n",
    "f1_score_none = f1_score(y_true, y_pred, average=None)\n",
    "f1_score_micro = f1_score(y_true, y_pred, average='micro')\n",
    "f1_score_macro = f1_score(y_true, y_pred, average='macro')\n",
    "f1_score_weighted = f1_score(y_true, y_pred, average='weighted')\n",
    "f1_score_samples = f1_score(y_true, y_pred, average='samples')\n",
    "print(f1_score_none)\n",
    "print(f1_score_micro)\n",
    "print(f1_score_macro)\n",
    "print(f1_score_weighted)\n",
    "print(f1_score_samples)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "1011ab98-f2f3-4759-bf6f-cd26fece1ed8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6666666666666666\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import accuracy_score\n",
    "accuracy_score_value = accuracy_score(y_true, y_pred)\n",
    "print(accuracy_score_value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "82a21640-d93b-4a05-9f3a-4b1c4f2e7e6f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 0, 0, 0, 2]\n",
      "[1, 2, 0, 0, 0]\n",
      "[2, 0, 0, 2, 0]\n",
      "[3, 0, 2, 0, 0]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import confusion_matrix\n",
    "\n",
    "import numpy as np\n",
    "y_true = np.array([[1, 0, 1, 0], [1, 0, 1, 0]])\n",
    "y_pred = np.array([[1, 0, 0, 1], [1, 0, 0, 1]])\n",
    "\n",
    "from sklearn.metrics import multilabel_confusion_matrix\n",
    "multilabel_confusion_matrix_values = multilabel_confusion_matrix(y_true, y_pred)\n",
    "columns = ['tag', 'TN', 'FP', 'FN', 'TP']\n",
    "for i in range(len(multilabel_confusion_matrix_values)):\n",
    "    label_confusion_matrix_values = multilabel_confusion_matrix_values[i]\n",
    "    row = [i] + label_confusion_matrix_values.flatten().tolist()\n",
    "    print(row)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "e43cfb52-7102-4a10-9d93-b6bbd795c9af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.1235\n"
     ]
    }
   ],
   "source": [
    "print('{:.4f}'.format(0.12345))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "d5816df7-2215-4047-8b68-5518479600e9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[-1.0991e+00, -1.0341e+00, -1.7272e+00,  1.6678e+00, -1.5961e+00,\n",
      "         -1.4680e+00,  1.4096e+00,  7.0918e-01, -7.7327e-01,  9.1228e-01,\n",
      "         -6.0909e-01,  8.5620e-01,  1.4584e+00, -1.0158e+00, -1.4796e+00,\n",
      "         -1.1177e+00, -1.1457e+00, -1.1289e+00, -4.4065e-01, -1.2832e+00,\n",
      "         -1.4975e+00,  9.2452e-01,  1.2442e+00,  5.8214e-01, -1.1477e+00,\n",
      "          3.6348e-01,  1.5423e+00, -1.6788e+00,  1.4408e+00,  5.9378e-02,\n",
      "         -8.0817e-01,  1.5989e+00,  1.6030e+00,  9.4712e-01, -8.1257e-01,\n",
      "         -1.6009e+00,  3.7108e-01,  1.1090e-01,  1.4573e+00, -8.4801e-01,\n",
      "          1.6037e+00, -7.7952e-01, -1.0650e+00,  2.0090e-03,  1.4103e+00,\n",
      "         -3.8346e-01,  1.1276e+00,  5.5089e-03, -1.6320e+00, -1.2507e+00,\n",
      "          1.4571e+00, -2.8588e-01,  5.5116e-01,  4.7833e-01,  1.0924e+00,\n",
      "          5.6755e-01,  1.2602e+00, -3.3968e-01,  1.6296e+00, -1.6225e-01,\n",
      "          4.3750e-01,  1.0107e+00, -1.4448e+00, -3.6813e-01,  1.0972e+00,\n",
      "          1.0288e+00,  3.9664e-01, -1.5262e+00,  1.0050e+00, -7.1012e-01,\n",
      "         -6.1706e-01, -6.6244e-01, -1.2511e+00, -1.6026e+00, -5.3400e-02,\n",
      "         -1.1629e+00, -1.0126e+00, -1.9210e-01,  1.7297e+00, -2.2670e-01,\n",
      "          9.3901e-01, -1.3204e+00,  1.1219e-01,  5.8883e-01, -1.2172e+00,\n",
      "          9.5205e-01,  2.4561e-01, -1.7084e+00, -5.7824e-01,  9.7562e-01,\n",
      "          5.5904e-01, -1.3581e+00,  7.8229e-01, -1.4673e+00, -7.5161e-02,\n",
      "          1.1799e+00,  4.1793e-01, -2.0284e-01, -6.8591e-01, -1.5098e+00],\n",
      "        [ 1.2460e+00,  1.5098e+00,  6.7092e-01, -9.4203e-01, -5.4835e-02,\n",
      "          1.1663e+00, -1.2554e-03,  2.9066e-01, -8.7024e-01,  1.0684e+00,\n",
      "         -7.5241e-01, -5.0804e-01, -8.0500e-01,  1.3163e+00,  3.6302e-01,\n",
      "          1.5766e+00,  1.3114e+00, -4.9989e-02, -4.6292e-01,  4.8467e-01,\n",
      "          6.3119e-01,  2.9801e-01, -1.3827e+00,  1.3056e+00, -6.2743e-01,\n",
      "          2.3396e-01, -5.9104e-02,  8.8195e-01, -1.3792e+00,  1.5799e+00,\n",
      "         -5.3477e-01, -1.1606e+00, -4.8057e-01,  1.0418e+00,  1.6471e+00,\n",
      "          1.1569e+00, -1.4997e+00, -1.5859e+00,  3.8867e-01,  9.4667e-02,\n",
      "         -4.9291e-01,  1.0358e+00,  1.6396e+00, -1.5276e+00, -1.3826e+00,\n",
      "         -9.4167e-01,  7.0748e-01, -6.2411e-01,  7.5977e-01,  2.0381e-01,\n",
      "         -6.4321e-02, -8.0709e-01,  6.4136e-01,  1.8471e-01, -8.7464e-01,\n",
      "          1.3016e+00, -1.0942e+00,  8.8107e-01, -6.0225e-01,  8.5786e-01,\n",
      "         -1.1453e+00, -4.1813e-01,  1.2655e+00, -1.9697e-01, -1.4581e+00,\n",
      "          3.1493e-01, -2.4880e-01,  1.1566e+00, -1.2663e+00, -6.9087e-01,\n",
      "          1.3050e-01,  1.4797e+00,  6.6270e-01,  5.2220e-01,  1.1151e+00,\n",
      "          2.6027e-01, -5.6586e-01, -1.5342e+00, -6.1158e-01, -5.5767e-01,\n",
      "          4.7146e-01,  1.0710e+00,  1.5900e+00, -2.5367e-01,  1.4061e+00,\n",
      "          8.3519e-01,  1.2418e+00,  7.5455e-01, -8.9048e-01,  8.8104e-01,\n",
      "         -1.4821e+00,  1.1331e+00, -1.1576e+00,  2.9187e-01, -9.8778e-01,\n",
      "         -7.4240e-01,  1.4338e+00, -1.5055e+00, -6.6156e-02,  1.0255e+00],\n",
      "        [ 7.1035e-01, -7.5650e-01,  5.9400e-01, -5.4655e-01,  1.0337e+00,\n",
      "          6.1951e-01,  1.0371e-02,  7.0687e-01,  1.7396e-02, -8.1043e-01,\n",
      "          1.7142e+00,  1.0400e+00, -1.0379e+00,  6.2119e-01,  1.2848e+00,\n",
      "         -5.1204e-01, -7.7349e-01,  1.5965e+00,  1.7134e+00, -5.4934e-01,\n",
      "          1.1345e+00, -1.6857e+00, -4.4571e-01, -6.4844e-01,  2.9026e-01,\n",
      "          1.0493e+00, -2.3286e-01,  2.3177e-01, -1.3084e-01, -5.3969e-01,\n",
      "         -3.6755e-01, -2.0282e-01, -1.0949e+00, -8.5366e-01, -7.9027e-01,\n",
      "          2.2721e-01,  1.2629e+00,  2.9886e-01, -1.0254e+00, -8.4564e-01,\n",
      "         -1.0885e+00, -1.1974e+00, -3.6565e-01,  2.6158e-01, -2.3640e-01,\n",
      "         -3.5925e-01, -1.4392e+00, -9.9820e-01,  9.1185e-04, -4.3730e-01,\n",
      "         -1.3682e+00, -6.0884e-01, -1.7307e+00,  9.9454e-01, -1.1133e+00,\n",
      "         -1.2787e+00,  6.9182e-01,  9.4622e-01, -3.7232e-02, -1.5717e+00,\n",
      "          1.4137e+00, -1.4426e+00,  4.7368e-01, -1.0713e+00,  7.2942e-01,\n",
      "         -1.6567e+00,  1.2990e+00, -1.7880e-01, -6.9155e-01,  1.7096e+00,\n",
      "          1.5630e+00, -1.1288e+00,  1.2488e+00,  4.0287e-03, -1.5773e+00,\n",
      "         -5.9091e-01,  1.6284e+00,  1.1070e+00, -6.2520e-01,  1.6825e+00,\n",
      "         -1.6801e+00, -6.0953e-01, -7.7878e-01, -1.4966e+00, -6.0576e-01,\n",
      "         -1.5257e+00,  5.9810e-02,  3.0834e-01,  1.6815e+00, -4.0565e-01,\n",
      "         -2.6813e-01,  7.6302e-01,  1.1817e+00, -1.4413e-01,  1.6391e+00,\n",
      "          7.7146e-01, -1.0916e+00,  1.1955e+00, -8.9713e-01,  7.6729e-01],\n",
      "        [-8.5721e-01,  2.8074e-01,  4.6229e-01, -1.7923e-01,  6.1725e-01,\n",
      "         -3.1780e-01, -1.4187e+00, -1.7067e+00,  1.6261e+00, -1.1702e+00,\n",
      "         -3.5270e-01, -1.3882e+00,  3.8452e-01, -9.2161e-01, -1.6823e-01,\n",
      "          5.3146e-02,  6.0777e-01, -4.1759e-01, -8.0982e-01,  1.3478e+00,\n",
      "         -2.6821e-01,  4.6316e-01,  5.8420e-01, -1.2393e+00,  1.4849e+00,\n",
      "         -1.6468e+00, -1.2504e+00,  5.6511e-01,  6.9322e-02, -1.0996e+00,\n",
      "          1.7105e+00, -2.3545e-01, -2.7495e-02, -1.1353e+00, -4.4266e-02,\n",
      "          2.1678e-01, -1.3428e-01,  1.1761e+00, -8.2057e-01,  1.5990e+00,\n",
      "         -2.2255e-02,  9.4111e-01, -2.0895e-01,  1.2640e+00,  2.0877e-01,\n",
      "          1.6844e+00, -3.9591e-01,  1.6168e+00,  8.7133e-01,  1.4842e+00,\n",
      "         -2.4533e-02,  1.7018e+00,  5.3814e-01, -1.6576e+00,  8.9552e-01,\n",
      "         -5.9041e-01, -8.5782e-01, -1.4876e+00, -9.9008e-01,  8.7607e-01,\n",
      "         -7.0591e-01,  8.4996e-01, -2.9432e-01,  1.6364e+00, -3.6854e-01,\n",
      "          3.1297e-01, -1.4468e+00,  5.4841e-01,  9.5294e-01, -3.0861e-01,\n",
      "         -1.0765e+00,  3.1159e-01, -6.6038e-01,  1.0764e+00,  5.1553e-01,\n",
      "          1.4936e+00, -4.9948e-02,  6.1931e-01, -4.9295e-01, -8.9816e-01,\n",
      "          2.6968e-01,  8.5897e-01, -9.2342e-01,  1.1614e+00,  4.1677e-01,\n",
      "         -2.6159e-01, -1.5472e+00,  6.4547e-01, -2.1277e-01, -1.4510e+00,\n",
      "          1.1912e+00, -5.3805e-01, -8.0638e-01,  1.3195e+00, -5.7614e-01,\n",
      "         -1.2089e+00, -7.6020e-01,  5.1287e-01,  1.6492e+00, -2.8308e-01]],\n",
      "       grad_fn=<NativeBatchNormBackward>)\n"
     ]
    }
   ],
   "source": [
    "m = nn.BatchNorm1d(100)\n",
    "# m = nn.BatchNorm1d(100, affine=False)\n",
    "input = torch.randn(4, 100)\n",
    "output = m(input)\n",
    "print(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f7d17e37-e170-4520-97df-0605f7d70dfb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
